using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public static class UIExtend 
{
      /// <summary>
    /// 添加子物体
    /// </summary>
    /// <param name="parent">父节点</param>
    /// <param name="prefab">节点原型</param>
    /// <param name="layer">节点层级</param>
    /// <returns></returns>
    public static GameObject AddChild(this Transform parent, GameObject prefab, int layer = -1)
    {
        return UISvc.AddChild(parent, prefab, layer);
    }

    /// <summary>
    /// 确保子物体数量（若不足则拷贝补足）
    /// </summary>
    /// <param name="parent">父节点</param>
    /// <param name="count">子节点个数</param>
    /// <param name="active">状态</param>
    /// <param name="prefab">节点原型</param>
    public static void EnsureChild(this Transform parent, int count, bool active = false, GameObject prefab = null)
    {
        UISvc.EnsureChild(parent, count, active, prefab);
    }

    /// <summary>
    /// 遍历所有子物体
    /// </summary>
    /// <param name="parent">父节点</param>
    /// <param name="handler">回调函数</param>
    public static void EachChild(Transform parent, UISvc.EachChildHandler handler)
    {
        UISvc.EachChild(parent,handler);
    }

    /// <summary>
    /// 显示所有子物体
    /// </summary>
    /// <param name="parent">父节点</param>
    /// <param name="handler">回调函数</param>
    public static void ShowChild(this Transform parent, UISvc.EachChildHandler handler = null)
    {
        UISvc.ShowChild(parent, handler);
    }
 
}
